﻿using System;

namespace params可变参数
{
	//params必须是形参里面最后一个
	class Program
	{
		static void Main(string[] args)
		{
			Test("张三", 39, 21, 54);
			Console.ReadKey();
		}
		public static void Test(string name,params int[] a)
		{
			int sum = 0;
			for(int i = 0; i < a.Length; i++)
			{
				sum += a[i];
			}
			Console.WriteLine("{0}的成绩总和为{1}",name,sum);
		}
	}
}
